<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<?php
	
	function dbconnect() 
	{ 
		require('config.php'); 
		static $connect = null; 
		if ($connect === null) 
			{
				 $connect =  mysql_connect($host, $user, $passwd) or die(mysql_error());
				 mysql_query("SET character_set_results=utf8", $connect);
				 mysql_select_db($database); 
			} 
		return $connect; 
	} 
	
	function insert_ttp($post) 
	{ 
	 
		$query= mysql_query("INSERT INTO Tinh_thanh_pho SET Ten_tinh_thanh_pho=N'".$post['Ten_tinh_thanh_pho']."'", dbconnect());  
		
	}
	
	function getid_auto_increment()
	{
		
		$r= mysql_query("SHOW TABLE STATUS LIKE 'Tinh_thanh_pho'",dbconnect());
		$row = mysql_fetch_array($r); 
        $n = $row['Auto_increment']; 
        return $n;
		
		} 
	
	function getbyid_tinh($id)
	{
		$result= mysql_query("SELECT * FROM Tinh_thanh_pho WHERE ID=N'".$id."'",dbconnect());
		return mysql_fetch_array($result); 
	}
	
	
	function update_tinh($post)
	{
	$query= mysql_query("UPDATE Tinh_thanh_pho SET Ten_tinh_thanh_pho=N'".$post['Ten_tinh_thanh_pho']."' WHERE ID=N'".$post['ID']."' ",dbconnect()); 	
	}
	

	
	
	
?>
</body>
</html>